Skip to content

Add parameterized context-toggle keymap actions and expose toggle_context in public API#1

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-toggle-context-api
Draft

Add parameterized context-toggle keymap actions and expose toggle_context in public API#1
Copilot wants to merge 2 commits intomainfrom
copilot/add-toggle-context-api

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 12, 2026

We recently introduced public context toggling, and this follow-up improves usability by enabling concise keymap wiring for specific context toggles. This PR adds API-level exposure and keymap action parsing so users can configure entries like toggle_context#current_file.

  • Public API

    • Exposes require('opencode.api').toggle_context(context_key).
    • Delegates directly to opencode.context.toggle_context, making context toggling available through the main API surface.
  • Keymap action argument suffix (#...)

    • Extends keymap action resolution to support action#arg syntax.
    • Parses the action name into:
      • resolved function name (before #)
      • inline string argument (after #)
    • Preserves existing behavior for explicit second-argument keymap entries; inline suffix is additive.
  • Type/docs alignment

    • Updates keymap type annotation to document function_name#<arg> support.
    • Adds README usage example for context toggling via keymap.
  • Focused coverage

    • Adds unit coverage for:
      • api.toggle_context(...) delegation.
      • keymap dispatch of toggle_context#current_file and argument propagation.
require('opencode').setup({
  keymap = {
    editor = {
      ['<leader>ocf'] = { 'toggle_context#current_file', desc = 'Toggle current file context' },
    },
  },
})
Original prompt

We recently added a public API for toggling the prompt context. I can reference the exact commit if needed.

Now I would like to followup with some quality-of-life improvements for users. we could also add the toggle_context in the api file and configure it like so toggle_context#current_file where anything after the # is the param?


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add toggle context to API configuration Add parameterized context-toggle keymap actions and expose toggle_context in public API Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants